const http = require('http') ;
const fs = require('fs') ;

const server = http.createServer((req , res) => {
    // 判断路径   req.url
    if(req.url === '/home') {
        // res.end('<h1>home</h1>') ;
        fs.readFile('./home.html' , 'utf-8' , (err , data) => {
            if(err) {
                console.log(err) ;
            }
            res.end(data) ;
        })
    } 
    else if(req.url === '/reg') {
        res.end('<h1>reg</h1>') ;
    }
    else {
        res.end('404') ;
    }
})

server.listen(4000 , () => console.log('服务正在运行中...'));